<template>
	<view class="page">
		<img class="imges" src="../../static/index.png" alt="" />
		<view class="body-box">
			<view class="rule-box">
				<view class="title1">
					{{isShow?'您已成功领取立减金':'成功领取立减金后'}}，请前往微信
				</view>
				<view class="title2">
					【我】-【卡包】-【券和礼品卡】查看
				</view>
				<view class="neirong">
					<view class="neirongtitle">
						{{fromObj.goodsName}}
					</view>
					<view class="neirongtime" v-if="isShow">
						兑换时间:{{fromObj.updateTime}}
					</view>
				</view>
				<view class="rule-text">
					1.立减金可在张家界农商储蓄卡持卡人领取后支付大于领取的立减金面值时抵扣使用;
				</view>
				<view class="rule-text">
					2.使用立减金抵扣支付金额时，需使用张家界农商储蓄卡，其余银行无法使用权益抵扣;
				</view>
				<view class="rule-text">
					3.立减金不可用于转账、理财、少数特定商户(如CoCo奶茶、优衣库、星巴克、肯德基、必胜客、华头商城、Apple商城、零钱通、理财通等不支持抵扣)，权益不找零，不可用于兑换卡券;
				</view>
				<view class="rule-text">
					4.领取成功后，到账当日即可使用，过期不补;可在微信卡包中查看有效期:
				</view>
				<view class="rule-text">
					5.使用立减金的订单如发生全额退款，有效期内立减金退回卡包，其他情况下立减金不退还;
				</view>
				<view class="rule-text">
					6.微信支付亲属卡用户无法参与本活动。
				</view>
			</view>
		</view>
	</view>


</template>
	
<script>
	import login from "@/api/config"
	export default {
		data() {
			return {
				code: '',
				title: '刮刮乐活动',
				a: '',
				fromObj:{},
				isShow:false
			}
		},
		onLoad(e) {
			if (e.id) {
				this.code = e.id
			}
			// 开始请求保证登录
			this.initData();
			// this.test()
			//获取url中的参数


		},
		methods: {
			// test() {
			// 	login.getWeChatCode()
			// },
			// 领取兑换码
			formSubmit() {
				console.log(31)
				let that = this
				if (this.code == '' || this.code== null) {
					uni.showModal({
						title: '提示',
						content: '请填写您获取的兑换码',
						showCancel: false,
						success: function(res) {}
					});
				} else {
					this.$request('/scratchCards/exchange', {
						code: this.code
					}).then(res => {
						console.log(res)
						if (res.code == 0) {
							let entity = res.entity
							let text = '您已成功领取立减金，请前往微信【我】【卡包】-【券和礼品卡】查看'
							uni.showModal({
								title: '提示',
								content: text,
								showCancel: false,
								success: function(res) {
									that.isExchange()
								}
							});
						} else if (res.code !== 0) {
							uni.showModal({
								title: '提示',
								content: res.msg,
								showCancel: false,
								success: function(res) {

								}
							});
						}
					})
				}

			},
			// 判断是否兑换
			isExchange(){
				this.$request('/scratchCards/codeDetail', {
					code: this.code
				}).then(res => {
					if(res.code==0){
						this.fromObj = res.codeDetail
						if(res.codeDetail.valid==1){
							this.isShow = false
							this.formSubmit()
						}else if(res.codeDetail.valid==0){
							this.isShow = true
						}
						this.$forceUpdate()
					}else{
						uni.showModal({
							title: '提示',
							content: res.msg,
							showCancel: false,
							success: function(res) {
						
							}
						});
					}
				})
			},
			getParam(path, name) {
				var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
				if (reg.test(path))
					return unescape(RegExp.$2.replace(/\+/g, " "));
			},
			vininput(e) {
				let val = e.detail.value;
				this.code = val; //这里对应的是value绑定的变量
				return val; // 最后输出值，要保证输入框的值和value绑定的值一致
			},
			initData() {
				this.$request('/user/userInfo').then(res => {
					if (res.code == 0) {
						this.isExchange();
					}
				})
			},
			varify() {
				let that = this
				let appid = '190629257'; // 腾讯云控制台中对应这个项目的 appid
				// 生成一个滑块验证码对象
				let captcha = new TencentCaptcha(appid, function(res) {
					if (res.ret === 0) {
						console.log()
						console.log("进入判断")
						that.formSubmit();
						//成功，传递数据给后台进行验证
					}
				});

				// 滑块显示
				captcha.show();
			},
		},
	}
</script>

<style>
	.page {
		height: 100vh;
		width: 100vw;
		/* background-color: #FFFFFF;
		background: url(../../static/index.png) no-repeat;
		background-size: 100% 100%; */
		overflow: hidden;
	}
	.imges{
		display: block;
		width: 100vw;
		position: fixed;
		top: 0;
		left: 0;
	}

	.body-box {
		display: flex;
		justify-content: center;
		margin: 0 auto;
		margin-top: 340rpx;
	}

	.body {
		justify-content: center;
		width: 500rpx;
		height: 464rpx;
		background: url(../../static/index24.jpg) no-repeat;
		background-size: 100% 100%;
		position: relative;
		border-radius: 30rpx;
	}
	.body2{
		justify-content: center;
		width: 500rpx;
		height: 264rpx;
		background-color: #fff;
		background-size: 100% 100%;
		position: relative;
		border-radius: 30rpx;
		padding: 20rpx;
		margin-top: 100rpx;
	}
	.bodyTitle{
		font-weight: bold;
		color: rgb(106, 106, 106);
		font-size: 28rpx;
	}
	.bodyList{
		box-sizing: border-box;
		margin-top: 30rpx;
		font-size: 26rpx;
	}
	.bodyList span{
		font-weight: bold;
	}

	.form-box {
		position: absolute;
		width: 400rpx;
		top: 140rpx;
		left: 50%;
		margin-left: -200rpx;

	}

	.form-input {
		background-color: #f5443a;
		padding: 12rpx;
		text-align: center;
		border-radius: 12rpx;
		color: #FFFFFF;
		font-size: 28rpx;
	}

	.button-box {
		width: 400rpx;
		position: absolute;
		bottom: 15rpx;
		left: 50%;
		margin-left: -200rpx;
	}

	.form-button {
		width: 400rpx;
		height: 60rpx;
		border-radius: 50rpx;
		line-height: 60rpx;
		background-color: #f5443a;
		font-size: 28rpx;
	}

	.rule-box {
		position: absolute;
		top: 672rpx;
		margin: 0 30rpx;
		width: 674rpx;
		height: 726rpx;
		background: url('../../static/kuang.png') no-repeat;
		background-size: 100% 100%;
		box-sizing: border-box;
		padding: 15rpx;
		border-radius: 25rpx;
	}
	.title1{
		font-weight: 500;
		font-size: 32rpx;
		color: #F84B49;
		margin-top: 22rpx;
		text-align: center;
	}
	.title2{
		font-weight: 500;
		font-size: 32rpx;
		color: #F84B49;
		margin-top: 16rpx;
		text-align: center;
	}
	.neirong{
		width: 600rpx;
		height: 168rpx;
		background: url('../../static/neirong.png') no-repeat;
		background-size: 100% 100%;
		margin: 20rpx auto 10rpx;
		overflow: hidden;
	}
	.neirongtitle{
		font-weight: bold;
		font-size: 56rpx;
		color: #E9411F;
		margin-top: 25rpx;
		text-align: center;
	}
	.neirongtime{
		font-weight: 400;
		font-size: 20rpx;
		color: #E9411F;
		text-align: center;
		margin-top: 5rpx;
	}
	.rule-text {
		font-size: 20rpx;
		font-weight: 500;
		color: #A96C69;;
		width: 576rpx;
		letter-spacing: 4rpx;
		margin: 0 auto;
	}

	.startshow {
		position: fixed;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		z-index: 99999;
	}

	.startshow .startshow-phone-box {
		position: absolute;
		top: 45%;
		left: 50%;
		width: 580rpx;
		height: 500rpx;
		transform: translate(-50%, -50%);
		text-align: center;
		background: #f8f8f8;
		border-radius: 30rpx;
		padding: 30rpx;
		display: flex;
		align-items: center;
	}

	.startshow .startshow-phone-box .startshow-phon-title {
		padding: 20rpx;
		letter-spacing: 4rpx;
		font-weight: 700;
		color: #3057e7;
	}

	.startshow .startshow-phone-box .startshow-phone {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.startshow .startshow-phone-box .startshow-button {
		width: 240rpx;
		background: #3057e7;
		border-radius: 30rpx;
		color: #fff;
		text-align: center;
		letter-spacing: 8rpx;
		padding: 10rpx;
		font-size: 36rpx;
		margin: 20rpx;
	}

	.startshow .startshow-phone-box .startimgoff {
		position: absolute;
		top: 120%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 60rpx;
		height: 60rpx;
	}

	.startshow .startshow-box {
		position: absolute;
		top: 45%;
		left: 50%;
		width: 580rpx;
		height: 625rpx;
		transform: translate(-50%, -50%);
		text-align: center;
		background: url("https://lybank-1302786294.cos.ap-guangzhou.myqcloud.com/shops/images/20220524/4e181ced71904df4b8d5d28e0a366f7d.png");
		background-size: 100% 100%;
	}

	.startshow .startshow-box .startshowb-title {
		font-size: 58rpx;
		font-weight: bold;
		color: #fff;
		padding-top: 60rpx;
		padding-left: 15rpx;
		height: 140rpx;
	}

	.startshow .startshow-box .startshowb-button {
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding-left: 15rpx;
		padding-top: 290rpx;
	}

	.startshow .startshow-box .startshowb-button view {
		font-weight: 700;
		color: #7d3311;
		width: 220rpx;
		padding: 15rpx;
		background: #fdd354;
		text-align: center;
		border-radius: 50rpx;
	}

	.startshow .startshow-box .startimgoff {
		position: absolute;
		top: 120%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 60rpx;
		height: 60rpx;
	}

	.startshow .startshow-boxer {
		position: absolute;
		top: 45%;
		left: 50%;
		width: 580rpx;
		height: 625rpx;
		transform: translate(-50%, -50%);
		text-align: center;
		/* background: url("https://lybank-1302786294.cos.ap-guangzhou.myqcloud.com/shops/images/20220524/5c7ace70b2bc4bc6bfe93e52fb1f2705.png");
		background-size: 100% 100%; */
		padding-left: 15rpx;
	}

	.changan {
		display: block;
		width: 100%;
		height: 100%;
		position: absolute;
	}

	.startshow .startshow-boxer .qrcode {
		width: 330rpx;
		height: 330rpx;
		margin-top: 50rpx;
	}

	.startshow .startshow-boxer .qrcode-title {
		font-size: 42rpx;
		font-weight: bold;
		color: #333333;
		padding-top: 140rpx;
	}

	.startshow .startshow-boxer .startimgoff {
		position: absolute;
		top: 120%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 60rpx;
		height: 60rpx;
	}
</style>
